#pragma once
#include"HashTable.hpp"
namespace bit
{
template<class K,class Hash=hash_bucket::HashFunc<K>>
class unordered_set
{
public:
    class SetKeyOfT
    {
    public:
        const K& operator()(const K& key)
        {
            return key;
        }
    };
    
    typedef typename hash_bucket::HashTable<K, const K, SetKeyOfT,Hash>::const_iterator const_iterator;

    const_iterator begin() const
    {
        return _ht.begin();
    }
    
    const_iterator end() const
    {
        return _ht.end();
    }
    
    pair<const_iterator, bool> insert(const K& key)
    {
        auto ret=_ht.Insert(key);
        return pair<const_iterator, bool>(const_iterator(ret.first._node,ret.first._pht,ret.first._hashi),ret.second);
    }
private:
    hash_bucket::HashTable<K,const K,SetKeyOfT,Hash> _ht;
};
void test_set()
{
    //xcode的遍历是从第一个桶遍历的，而
    unordered_set<int> us;
    std::unordered_set<int> us1;
    
    us.insert(11);
    us.insert(30);
    us.insert(10);
    us.insert(21);
    
    us1.insert(11);
    us1.insert(30);
    us1.insert(10);
    us1.insert(21);
    
    unordered_set<int>::const_iterator it=us.begin();
    std::unordered_set<int>::iterator it1=us1.begin();
    while(it!=us.end())
    {
        cout<<*it<<"    "<<endl;
        //
        ++it;
    }
    cout<<endl;
    
    while(it1!=us1.end())
    {
        cout<<*it1<<"    "<<endl;
        ++it1;
    }
    cout<<endl;
}
}

